Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Git repos with multiple remotes configured #1782

Merged
merged 6 commits into from
Oct 29, 2024

Conversation

Seb-MCaw
Copy link
Contributor

A Git repo may have multiple remotes configured, often with different branches tracking different remotes. For example, development may be done on a private repository, with release/production versions available on a public repository.

Currently Alire assumes there is at most one remote, and therefore ends up using whichever is first alphabetically when there is more than one. In practice, this is only relevant to alr publishing, since dependencies are always fetched as a plain git clone, which does indeed yield a repo with only one remote.

This PR makes this assumption more explicit where applicable, and adds a subprogram to Alire.Publish.Local_Repository which attempts to guess the appropriate remote when there is more than one.

@Seb-MCaw Seb-MCaw force-pushed the feat/multiple-git-remotes branch from d1985d2 to a207905 Compare October 14, 2024 12:32
@Seb-MCaw Seb-MCaw changed the title Add support for git repos with multiple remotes configured Add support for Git repos with multiple remotes configured Oct 14, 2024
@Seb-MCaw Seb-MCaw force-pushed the feat/multiple-git-remotes branch from 6441345 to 77992da Compare October 14, 2024 14:29
@Seb-MCaw Seb-MCaw marked this pull request as ready for review October 14, 2024 16:21
@Seb-MCaw
Copy link
Contributor Author

This one is ready for review too, @mosteo. You can ignore my previous (deleted) comment.

@Seb-MCaw Seb-MCaw force-pushed the feat/multiple-git-remotes branch from 77992da to 6a29f1c Compare October 16, 2024 09:35
Conflicts in:
- src/alire/alire-publish.ads
Comment on lines 52 to 64
def commit_file(commit_name: str, path: str, content: str):
"""
Create a new file with the specified content and `git commit` it.

Also returns the commit's hash and attaches the tag `f"tag_{commit_name}"`
thereto.
"""
with open(path, "x") as f:
f.write(content)
run(["git", "add", path])
run(["git", "commit", "-m", f"Commit {commit_name}"])
run(["git", "tag", f"tag_{commit_name}"])
return git_head()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in helpers.py named as git_commit_file, for general availability?

Copy link
Member

@mosteo mosteo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor refactor.

@Seb-MCaw
Copy link
Contributor Author

I'm assuming this is transient.

@Seb-MCaw Seb-MCaw requested a review from mosteo October 28, 2024 13:24
@mosteo
Copy link
Member

mosteo commented Oct 28, 2024

I'm assuming this is transient.

Yes it is.

@mosteo mosteo merged commit 15addad into alire-project:master Oct 29, 2024
24 checks passed
@mosteo
Copy link
Member

mosteo commented Oct 29, 2024

Merged, thanks.

@Seb-MCaw Seb-MCaw deleted the feat/multiple-git-remotes branch October 29, 2024 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants